package com.qk.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * @author 28188
 */

// 线索状态
@Getter
public enum ClueState {
    UNASSIGNED(1, "待分配"),
    PENDING_FOLLOWUP(2, "待跟进"),
    FOLLOWING_UP(3, "跟进中"),
    FAKE_LEAD(4, "伪线索"),
    CONVERTED_TO_OPPORTUNITY(5, "转为商机");

    // getters
    private final int code;
    private final String desc;

    ClueState(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ClueState fromCode(int code) {
        return Arrays.stream(values())
                .filter(state -> state.getCode() == code)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("无效状态码: " + code));
    }

}